Skip to content

feat(typescript-web): add WebAssembly runtime foundations - #4091

Closed
sxlijin wants to merge 1 commit into
canaryfrom
sam/typescript-web-wasm-runtime
Closed

sxlijin wants to merge 1 commit into
canaryfrom
sam/typescript-web-wasm-runtime

Conversation

@sxlijin

@sxlijin sxlijin commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add the sys_wasm crate with browser and Workers implementations built on the existing SysOps APIs
  • add WebAssembly-only bridge_cffi source initialization and handle/media support without changing the native or Python bridge surface
  • complete the raw TypeScript Web bridge exports, generated declarations, packaging, and focused browser/workerd tests

Why

The lower PR in the TypeScript Web stack imported sys_wasm from a later commit, so it could not build independently. This change makes the raw WebAssembly runtime a self-contained foundation while leaving shared engine and TypeScript API changes for the stacked integration PR.

Impact

Browser and Workers consumers gain a buildable raw WebAssembly runtime foundation. Native bridge_cffi behavior remains unchanged because the new CFFI and handle-table hooks are gated to wasm32.

Validation

  • cargo check -p bridge_typescript_web --target wasm32-unknown-unknown
  • cargo clippy -p bridge_typescript_web --target wasm32-unknown-unknown -- -D warnings
  • cargo check -p bridge_cffi
  • pnpm build:wasm
  • pnpm build:ts
  • pnpm test:web: 10 passed
  • pnpm test:workers: 10 passed

Summary by CodeRabbit

  • New Features
    • Added WebAssembly runtime support for browser execution, including HTTP fetch and synchronous file reads.
    • Introduced raw media handle creation/inspection for URL, file, and base64 inputs.
    • Implemented host-callable registration, host-call completion, release handling, and runtime initialization from in-memory source files.
    • Added type-checked handle cloning/release plus WASM-side host-value registry and version/event APIs.
  • Tests
    • Added Vitest/Playwright and worker test coverage for handles, media, host values, and runtime behavior.
  • Chores
    • Updated TypeScript WASM bridge exports and added wasm-declaration consistency checks.

@vercel

vercel Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment Jul 20, 2026 8:22am
promptfiddle Ready Ready Preview, Comment Jul 20, 2026 8:22am
promptfiddle2 Ready Ready Preview, Comment Jul 20, 2026 8:22am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 50132106-5595-4ad2-8b1c-b94a25e5e299

📥 Commits

Reviewing files that changed from the base of the PR and between a1c1154 and 81a72ae.

⛔ Files ignored due to path filters (2)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/sdks/typescript/bridge_typescript_web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (37)
  • baml_language/.cargo/size-gate.toml
  • baml_language/.ci/size-gate/aarch64-apple-darwin.toml
  • baml_language/.ci/size-gate/wasm32-unknown-unknown.toml
  • baml_language/.ci/size-gate/x86_64-pc-windows-msvc.toml
  • baml_language/.ci/size-gate/x86_64-unknown-linux-gnu.toml
  • baml_language/Cargo.toml
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/crates/bridge_cffi/src/handle.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_ctypes/src/handle_table.rs
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/crates/sys_wasm/src/host_value.rs
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/crates/sys_wasm/src/send_wrapper.rs
  • baml_language/crates/sys_wasm/src/web_sysops.rs
  • baml_language/sdk_tests/crates/typescript_web/setup.ps1
  • baml_language/sdk_tests/crates/typescript_web/setup.sh
  • baml_language/sdks/typescript/bridge_typescript_web/Cargo.toml
  • baml_language/sdks/typescript/bridge_typescript_web/package.json
  • baml_language/sdks/typescript/bridge_typescript_web/pnpm-workspace.yaml
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/src/errors.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/handle.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/host_value.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/lib.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/media.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/runtime.rs
  • baml_language/sdks/typescript/bridge_typescript_web/tests/bridge-web-core.d.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/host_value_registry.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/wasm_exports.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/worker.js
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/wasm/bridge_web_core.d.ts
  • baml_language/sdks/typescript/bridge_typescript_web/vitest.web.config.ts
  • baml_language/sdks/typescript/bridge_typescript_web/vitest.workers.config.ts
  • baml_language/sdks/typescript/bridge_typescript_web/wrangler.test.jsonc
🚧 Files skipped from review as they are similar to previous changes (25)
  • baml_language/sdks/typescript/bridge_typescript_web/tests/worker.js
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/Cargo.toml
  • baml_language/sdks/typescript/bridge_typescript_web/wrangler.test.jsonc
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/sdks/typescript/bridge_typescript_web/src/host_value.rs
  • baml_language/sdks/typescript/bridge_typescript_web/tests/bridge-web-core.d.ts
  • baml_language/sdks/typescript/bridge_typescript_web/pnpm-workspace.yaml
  • baml_language/sdks/typescript/bridge_typescript_web/src/runtime.rs
  • baml_language/crates/sys_wasm/src/send_wrapper.rs
  • baml_language/sdks/typescript/bridge_typescript_web/tests/host_value_registry.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/package.json
  • baml_language/sdks/typescript/bridge_typescript_web/tests/wasm_exports.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/src/errors.rs
  • baml_language/crates/bridge_ctypes/src/handle_table.rs
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/src/handle.rs
  • baml_language/crates/bridge_cffi/src/handle.rs
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjs
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/media.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/sys_wasm/src/web_sysops.rs
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/wasm/bridge_web_core.d.ts

📝 Walkthrough

Walkthrough

Adds a WASM web runtime bridge with host-call dispatch, browser HTTP/filesystem sysops, typed handle and media APIs, runtime initialization, TypeScript bindings, declaration synchronization, and browser/worker tests.

Changes

WASM web bridge

Layer / File(s) Summary
Runtime foundation
baml_language/Cargo.toml, baml_language/crates/bridge_cffi/*, baml_language/crates/bridge_ctypes/*, baml_language/crates/sys_wasm/*
Adds WASM workspace wiring, restricted source VFS initialization, handle-table introspection, sys_wasm configuration, and send wrappers.
Host-value dispatch and completion
baml_language/crates/sys_wasm/src/host_value.rs
Adds callable registries, in-flight completion tracking, cancellation cleanup, release callbacks, synchronous dispatch handling, and return-value validation.
Web HTTP and filesystem sysops
baml_language/crates/sys_wasm/src/web_sysops.rs, baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts
Bridges fetch and synchronous file reads through host callables, parses structured results, handles timeouts and response bodies, and wires web sysops during runtime initialization.
Handle, media, and runtime bindings
baml_language/sdks/typescript/bridge_typescript_web/src/*, typescript_src/wasm/bridge_web_core.d.ts
Exports runtime, host-value, handle, media, error, version, and event APIs through wasm-bindgen and updates generated declarations.
Web validation and packaging
baml_language/sdks/typescript/bridge_typescript_web/tests/*, scripts/*, vitest.*, wrangler.test.jsonc, package.json
Adds declaration checks, browser and worker test configuration, packaging setup, and tests for host registries, exports, handles, and media.

Artifact size baselines

Layer / File(s) Summary
Size-gate measurements and ceilings
baml_language/.cargo/size-gate.toml, baml_language/.ci/size-gate/*.toml
Refreshes recorded artifact metrics and platform-specific size-gate thresholds.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant BamlRuntime
  participant WebBridge
  participant WasmHost
  participant WebHttp
  participant JavaScript
  BamlRuntime->>WebBridge: initialize runtime
  WebBridge->>WasmHost: configure host callables
  WebHttp->>WasmHost: dispatch fetch request
  WasmHost->>JavaScript: invoke registered callable
  JavaScript-->>WasmHost: complete host call
  WasmHost-->>WebHttp: return parsed response
Loading

Poem

A rabbit hops through WASM bright,
With handles tucked in code tonight.
Fetches fly and files reply,
Host calls bloom beneath the sky.
Media paths now neatly sing—
Tests guard every web-bound thing.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding WebAssembly runtime foundations for the TypeScript web stack.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sam/typescript-web-wasm-runtime

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@vercel
vercel Bot temporarily deployed to Preview – beps July 20, 2026 07:08 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 20, 2026 07:16 Inactive
@github-actions

github-actions Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 25.3 MB 10.7 MB file 25.3 MB +0 B (+0.0%) OK
✅ packed-program Linux 🔒 17.0 MB 7.0 MB file 17.0 MB +0 B (+0.0%) OK
✅ baml-cli macOS 🔒 19.5 MB 9.3 MB file 19.5 MB +0 B (+0.0%) OK
✅ packed-program macOS 🔒 13.2 MB 6.2 MB file 13.2 MB +0 B (+0.0%) OK
✅ baml-cli Windows 🔒 21.1 MB 9.5 MB file 21.1 MB +0 B (+0.0%) OK
✅ packed-program Windows 🔒 14.1 MB 6.2 MB file 14.1 MB +0 B (+0.0%) OK
✅ bridge_wasm WASM 16.2 MB 🔒 4.4 MB gzip 4.4 MB -1 B (-0.0%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 20, 2026 07:29 Inactive
@sxlijin
sxlijin marked this pull request as ready for review July 20, 2026 07:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjs (1)

51-56: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

--check mode diffs raw file bytes, which is sensitive to line-ending differences.

checkedInSource !== browserSource is an exact string comparison of the full generated file. If the repo's checked-in file and a freshly-built dist/wasm/bridge_web_core.d.ts differ only in line endings (e.g., CRLF vs LF depending on git autocrlf/OS), this check will report false staleness. Consider normalizing line endings (or comparing the normalized export maps plus a content hash) before the exact-match check.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjs`
around lines 51 - 56, Update the --check branch in the sync-wasm-declarations
script to normalize line endings in both checkedInSource and browserSource
before comparing them, while preserving the existing stale-file error for
substantive content differences and the write behavior outside check mode.
baml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjs (1)

29-37: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Prepended imports could collide if workerd/index.js already imports the same bindings.

This unconditionally prepends import { readFileSync } from "node:fs"; and import { installReadFileSync } from "./native.js"; to the generated workerd/index.js. If the tsc/wasm-pack-generated entry ever imports node:fs (or re-exports installReadFileSync) itself, this produces a duplicate-binding SyntaxError at module load. Low risk today given the current generated output, but worth a defensive check (e.g., skip injection if the marker/import already exists) if this script runs more than once or the generated entry changes shape.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@baml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjs`
around lines 29 - 37, Update the injection logic in the workerd package
preparation script to detect whether the generated workerd index already
contains the prepended imports or installation marker before adding them. Skip
the injection when those bindings are present, while preserving the existing
setup for entries that do not contain them.
baml_language/sdks/typescript/bridge_typescript_web/src/media.rs (1)

35-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate handle-type validation logic vs. handle.rs::key_with_expected_type.

media_key re-implements the same "compare parts.handle_type to an expected type, else return unexpected_handle_type" logic already present in handle.rs's key_with_expected_type (same-crate, same file layer). Consider exposing key_with_expected_type (e.g. via crate::handle or a shared module) and having media_key delegate to it, e.g. key_with_expected_type(operation, parts, expected_handle_type(kind)), to keep the validation contract in one place.

Based on the handle.rs snippet shown in the graph context:

fn key_with_expected_type(
    operation: &'static str,
    parts: HandleParts,
    expected: BamlHandleType,
) -> Result<u64, JsError> { ... }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/typescript/bridge_typescript_web/src/media.rs` around
lines 35 - 45, Update media_key to reuse handle.rs::key_with_expected_type
instead of duplicating handle-type comparison and unexpected_handle_type error
construction. Expose key_with_expected_type through the crate as needed, pass
operation, parts, and expected_handle_type(kind), and preserve the existing
Result<u64, JsError> behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/sdks/typescript/bridge_typescript_web/src/lib.rs`:
- Around line 10-18: Gate the errors module with #[cfg(target_arch = "wasm32")]
alongside handle, host_value, media, and runtime. Keep its existing module
declaration and ensure errors is compiled only for wasm32 builds.

---

Nitpick comments:
In
`@baml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjs`:
- Around line 29-37: Update the injection logic in the workerd package
preparation script to detect whether the generated workerd index already
contains the prepended imports or installation marker before adding them. Skip
the injection when those bindings are present, while preserving the existing
setup for entries that do not contain them.

In
`@baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjs`:
- Around line 51-56: Update the --check branch in the sync-wasm-declarations
script to normalize line endings in both checkedInSource and browserSource
before comparing them, while preserving the existing stale-file error for
substantive content differences and the write behavior outside check mode.

In `@baml_language/sdks/typescript/bridge_typescript_web/src/media.rs`:
- Around line 35-45: Update media_key to reuse handle.rs::key_with_expected_type
instead of duplicating handle-type comparison and unexpected_handle_type error
construction. Expose key_with_expected_type through the crate as needed, pass
operation, parts, and expected_handle_type(kind), and preserve the existing
Result<u64, JsError> behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7436e7c4-8928-4b0f-9245-7b810cbc14c9

📥 Commits

Reviewing files that changed from the base of the PR and between fe33043 and a1c1154.

⛔ Files ignored due to path filters (2)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/sdks/typescript/bridge_typescript_web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (30)
  • baml_language/Cargo.toml
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/crates/bridge_cffi/src/handle.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_ctypes/src/handle_table.rs
  • baml_language/crates/sys_wasm/Cargo.toml
  • baml_language/crates/sys_wasm/src/host_value.rs
  • baml_language/crates/sys_wasm/src/lib.rs
  • baml_language/crates/sys_wasm/src/send_wrapper.rs
  • baml_language/crates/sys_wasm/src/web_sysops.rs
  • baml_language/sdks/typescript/bridge_typescript_web/Cargo.toml
  • baml_language/sdks/typescript/bridge_typescript_web/package.json
  • baml_language/sdks/typescript/bridge_typescript_web/pnpm-workspace.yaml
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/prepare-workerd-package.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/scripts/sync-wasm-declarations.mjs
  • baml_language/sdks/typescript/bridge_typescript_web/src/errors.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/handle.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/host_value.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/lib.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/media.rs
  • baml_language/sdks/typescript/bridge_typescript_web/src/runtime.rs
  • baml_language/sdks/typescript/bridge_typescript_web/tests/bridge-web-core.d.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/host_value_registry.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/wasm_exports.test.ts
  • baml_language/sdks/typescript/bridge_typescript_web/tests/worker.js
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts
  • baml_language/sdks/typescript/bridge_typescript_web/typescript_src/wasm/bridge_web_core.d.ts
  • baml_language/sdks/typescript/bridge_typescript_web/vitest.web.config.ts
  • baml_language/sdks/typescript/bridge_typescript_web/vitest.workers.config.ts
  • baml_language/sdks/typescript/bridge_typescript_web/wrangler.test.jsonc

Comment on lines +10 to +18
mod errors;
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen(js_name = callFunctionSync)]
pub fn call_function_sync(function_name: &str, encoded_args: &[u8]) -> Vec<u8> {
bridge_cffi::call_function_in_wasm_sync(function_name, encoded_args)
}

pub mod handle;
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen(js_name = callFunction)]
pub async fn call_function(function_name: &str, encoded_args: &[u8]) -> Vec<u8> {
bridge_cffi::call_function_in_wasm(function_name, encoded_args).await
}
pub mod host_value;
#[cfg(target_arch = "wasm32")]
pub mod media;
#[cfg(target_arch = "wasm32")]
pub mod runtime;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Inconsistent cfg gating on mod errors;.

handle, host_value, media, and runtime are all gated behind #[cfg(target_arch = "wasm32")], but mod errors; at Line 10 is not. Since errors.rs uses wasm_bindgen/js_sys types (JsValue, js_sys::Error) and is only consumed by the wasm32-gated modules, compiling it unconditionally means it becomes dead/unused code on any non-wasm32 build of this crate (e.g., a workspace-wide cargo check/cargo test --lib), and risks lint/dead-code noise or accidental breakage if errors.rs ever grows a non-wasm32-incompatible dependency.

🔧 Proposed fix
+#[cfg(target_arch = "wasm32")]
 mod errors;
 #[cfg(target_arch = "wasm32")]
 pub mod handle;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mod errors;
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen(js_name = callFunctionSync)]
pub fn call_function_sync(function_name: &str, encoded_args: &[u8]) -> Vec<u8> {
bridge_cffi::call_function_in_wasm_sync(function_name, encoded_args)
}
pub mod handle;
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen(js_name = callFunction)]
pub async fn call_function(function_name: &str, encoded_args: &[u8]) -> Vec<u8> {
bridge_cffi::call_function_in_wasm(function_name, encoded_args).await
}
pub mod host_value;
#[cfg(target_arch = "wasm32")]
pub mod media;
#[cfg(target_arch = "wasm32")]
pub mod runtime;
#[cfg(target_arch = "wasm32")]
mod errors;
#[cfg(target_arch = "wasm32")]
pub mod handle;
#[cfg(target_arch = "wasm32")]
pub mod host_value;
#[cfg(target_arch = "wasm32")]
pub mod media;
#[cfg(target_arch = "wasm32")]
pub mod runtime;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/typescript/bridge_typescript_web/src/lib.rs` around lines
10 - 18, Gate the errors module with #[cfg(target_arch = "wasm32")] alongside
handle, host_value, media, and runtime. Keep its existing module declaration and
ensure errors is compiled only for wasm32 builds.

@sxlijin
sxlijin force-pushed the sam/typescript-web-wasm-runtime branch from a1c1154 to 81a72ae Compare July 20, 2026 08:01
@vercel
vercel Bot temporarily deployed to Preview – beps July 20, 2026 08:02 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 20, 2026 08:09 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 20, 2026 08:22 Inactive
@sxlijin sxlijin closed this Jul 20, 2026
@sxlijin
sxlijin deleted the sam/typescript-web-wasm-runtime branch July 20, 2026 08:24
meefs pushed a commit to meefs/baml that referenced this pull request Jul 20, 2026
…yML#4006)

## Summary

- integrate the TypeScript Web bridge with the shared engine and
TypeScript runtime APIs
- fill out browser and Cloudflare Workers system operations and connect
generated SDKs to the functional runtime
- remove the Web and Workers Vitest ignore annotations once the complete
SDK surface is available

## Stack

This PR is based on BoundaryML#4091. The parent provides the independently
buildable raw WebAssembly runtime, target-gated CFFI hooks, packaging,
and focused browser/workerd tests. This PR layers the shared engine and
TypeScript API changes plus full generated SDK parity on top.

## Validation

- cargo nextest run -p sdk_test_typescript_web -E all() --no-fail-fast:
26 passed, 0 skipped
- TypeScript Web SDK matrix passes on Linux, macOS, and Windows
- mise run fmt, mise run stow, and mise run clippy pass

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added Web runtime sysops for HTTP `_fetch/_send` and synchronous
filesystem reads.
* Expanded the Web bridge with runtime initialization, plus exported
handle/media utilities and host-call lifecycle support.
* Added `getVersion`/`flushEvents` and strengthened call-context
lifecycle handling for Web.
* **Bug Fixes**
* Improved host-value/callable validation, stricter error/panic
decoding, and safer cancellation/detach behavior.
  * Enhanced type-context conversions for arrays/maps/instance fields.
* **Tests**
* Expanded SDK Web test coverage (Web + Workers) and improved fixture
harness generation.
* **Chores**
* Refreshed size-gate baselines and updated Web wasm/type declaration
sync tooling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

This branch was previously deployed

3 inactive deployments
Preview – promptfiddle — 81a72ae5 Deployed Jul 20, 2026 by vercel[bot]
Preview – promptfiddle2 — 81a72ae5 Deployed Jul 20, 2026 by vercel[bot]
Preview – beps — 81a72ae5 Deployed Jul 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant